__author__ = 'skynet'
from director.config import *

def getLocalizationsLib():
    collect=getCollection('localizations', getDB('config'))
    return collect.find()

def getLocalizationbyName(name):
    collect=getCollection('localizations', getDB('config'))
    result=collect.find_one({'name':name})
    del result['name']
    del result['_id']
    return result

def addLocalization(name):
    local=getCollection('localizations', getDB('config'))
    local.insert({'name':name})

def updateLocalization(name, value):
    local=getCollection('localizations', getDB('config'))
    local.update({'name':name}, {"$set": value})

def deleteLocalization(name):
    local=getCollection('localizations', getDB('config'))
    local.remove({'name':name})

def addAttribute(attributeName, attributeValue, localizationName):
    local=getCollection('localizations', getDB('config'))
    local.update({'name':localizationName}, {"$set": {attributeName: attributeValue}})

def deleteAttribute(attributeName, localizationName):
    local=getCollection('localizations', getDB('config'))
    local.update({'name':localizationName}, {"$pull": {attributeName:'sdgdfg'}})

def updateAttribute(attributeName, attributeValue, localizationName):
    local=getCollection('localizations', getDB('config'))
    local.update({'name':localizationName}, {"$set": {attributeName: attributeValue}})